<?php

/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the 
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program.  If not, see 
 * <http://www.gnu.org/licenses/>.
*/


// no direct access
defined('_JEXEC') or die('Restricted access');

$rows  = $this->get('List');
$page  = $this->get('Pagination');
$lists = $this->getLists();
JHTML::_('behavior.tooltip');

$rowsCount = count($rows);

?>
<form action="index.php?option=com_massmailer&amp;controller=Subscribers" method="post" name="adminForm">

	<table>
		<tr>
			<td width="100%">
				<?php echo JText::_( 'Filter' ) ?>:
				<input type="text" name="search" id="search" value="<?php echo $lists['search'] ?>" class="text_area" onchange="document.adminForm.submit();" />
				<button onclick="this.form.submit();"><?php echo JText::_( 'Go' ) ?></button>
				<button onclick="getElementById('search').value='';this.form.submit();"><?php echo JText::_( 'Reset' ) ?></button>
			</td>
		</tr>
	</table>

	<table class="adminlist" cellspacing="1">
	<thead>
		<tr>
			<th width="5">
				<?php echo JText::_( 'Num' ) ?>
			</th>
			<th width="5">
				<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo $rowsCount ?>);" />
			</th>
			<th class="title">
				<?php echo JHTML::_('grid.sort',   'Name', 's.name', $lists['order_Dir'], $lists['order']) ?>
			</th>
			<th width="30%">
				<?php echo JHTML::_('grid.sort',   'E-mail', 's.email', $lists['order_Dir'], $lists['order']) ?>
			</th>
			<th width="20%">
				<?php echo JHTML::_('grid.sort',   'Date', 's.created', $lists['order_Dir'], $lists['order']) ?>
			</th>
		</tr>
	</thead>

	<tbody>
	<?php
	$k = 0;
	for ($i = 0; $i < $rowsCount; $i++)
	{
		$row = &$rows[$i];

		$edit_link  = JRoute::_('index.php?option=com_massmailer&amp;controller=Subscribers&amp;task=edit&amp;cid=' . $row->id);
		$email_link = 'mailto:' . $row->email;
		$date       = JHTML::_('date', $row->created, JText::_('DATE_FORMAT_LC1'));
		$checked 	= JHTML::_('grid.id', $i, $row->id);
		?>
		<tr class="<?php echo "row$k" ?>">
			<td>
				<?php echo $page->getRowOffset( $i ) ?>
			</td>
			<td align="center">
				<?php echo $checked; ?>
			</td>
			<td>
				<a href="<?php echo $edit_link ?>">
					<?php echo htmlspecialchars($row->name, ENT_QUOTES, 'UTF-8') ?>
				</a>
			</td>
			<td align="center">
				<a href="<?php echo $email_link ?>">
					<?php echo htmlspecialchars($row->email, ENT_QUOTES, 'UTF-8') ?>
				</a>
			</td>
			<td><?php echo $date ?></td>
		</tr>
		<?php
		$k = 1 - $k;
	}
	?>
	</tbody>

	<tfoot>
		<tr>
			<td colspan="15">
				<?php echo $page->getListFooter() ?>
			</td>
		</tr>
	</tfoot>
	</table>

<input type="hidden" name="option" value="com_massmailer" />
<input type="hidden" name="controller" value="Subscribers" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="filter_order" value="<?php echo $lists['order'] ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $lists['order_Dir'] ?>" />
</form>
